< previous page page_270 next page >

Page 270
Knowing the Current Record
A recordset has a pointer that keeps track of the current record. There's only one current record for a Data control at any time. A recordset also has special positions known as beginning of file (BOF), before the first record, and end of file (EOF), after the last record. Because there's no current record when the record pointer is positioned at either of these, problems can occur.
By default, the Data control prevents these problems by setting the record pointer to the first record when the beginning of the file is reached or by setting the pointer to the last record when the end of the file is reached. This way, there's always a current record for viewing or editing. However, sometimes you need to know when you've actually reached the BOF or EOF position while using the Data control. You can control what the Data control does by setting the control's BOFAction and EOFAction properties.
The BOFAction property tells the Data control what action to take when the beginning of the file is reached. This property has two settings:
8694cbadb9b1ef7075903f6f95fc1db2.gif
0 - adDoMoveFirst, the default setting, executes the MoveFirst method to set the record pointer at the first record and the BOF flag to False.
8694cbadb9b1ef7075903f6f95fc1db2.gif
1 - adStayBOF sets the BOF flag to True.
The EOFAction property tells the Data control what action to take when the end of the file is reached. This property has three possible values:
8694cbadb9b1ef7075903f6f95fc1db2.gif
0 - adDoMoveLast, the default setting, executes the MoveLast method to set the record pointer to the last record and the EOF flag to False.
8694cbadb9b1ef7075903f6f95fc1db2.gif
1 - adStayEOF sets the EOF flag to True.
8694cbadb9b1ef7075903f6f95fc1db2.gif
2 - adAddNew executes the AddNew method to prepare for the addition of a new record.
Note
The
BOF and EOF actions are triggered only when users reach the beginning or end of the file by using the Data control's navigation buttons. They have no effect if you're using data-access methods (such as MoveNext) in your code.

Binding the Database
When you have the Data control on a form, you need to add one or more bound controls to connect to the Data control in order to easily access the data. Many of the controls that come with Visual Basic are set up to work with the Data control. These bound controls

 
< previous page page_270 next page >

If you like this book, buy it!